﻿using System;
using System.Web.UI.WebControls;
using BLL;

public partial class ProductRepair_RepairViewbySN : System.Web.UI.Page
{
    private Repair rep;
    private RepairItem repi;
    private string SN
    {
        get { return ViewState["SN"].ToString(); }
        set { ViewState["SN"] = value; }
    }

    public ProductRepair_RepairViewbySN()
    {
        rep = new Repair();
        repi = new RepairItem();
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string SN = this.TextBox1.Text.Trim();
        if (this.DropDownList1.SelectedValue == "按腔体序列号查询")
        {
            Bind1bySN(SN);
            Bind2bySN(SN);
        }
        else
        {
            Bind1byPackageSN(SN);
            Bind2byPackageSN(SN);
        }
    }

    protected void Bind1bySN(string SN)
    {
        this.GridView1.DataSource = rep.GetRepairbySN(SN);
        this.GridView1.DataBind();
    }

    protected void Bind2bySN(string SN)
    {
        this.GridView2.DataSource = repi.GetRepairItembySN(SN);
        this.GridView2.DataBind(); 
    }

    protected void Bind1byPackageSN(string SN)
    {
        this.GridView1.DataSource = rep.GetRepairbyPackageSN(SN);
        this.GridView1.DataBind();
    }

    protected void Bind2byPackageSN(string SN)
    {
        this.GridView2.DataSource = repi.GetRepairItembyPackageSN(SN);
        this.GridView2.DataBind(); 
    }

    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView1.PageIndex = e.NewPageIndex;
        if (this.DropDownList1.SelectedValue == "按腔体序列号查询")
        {
            Bind1bySN(SN);
        }
        else
        {
            Bind1byPackageSN(SN);
        }
    }

    protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        this.GridView2.PageIndex = e.NewPageIndex;
        if (this.DropDownList1.SelectedValue == "按腔体序列号查询")
        {
            Bind2bySN(SN);
        }
        else
        {
            Bind2byPackageSN(SN);
        }
    }
}
